#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 6e3 + 5;
const int MOD = 1e9 + 7;

int n, m;
struct Node {
  int x, y;
  bool operator<(const Node& o) const { return x < o.x; }
} a[N];
int f[N], g[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i].x >> a[i].y;
  sort(a + 1, a + n + 1);
  rep(i, 1, n) f[i] = g[i] = 1;
  per(i, n, 1) rep(j, 1, i - 1) {
    if (a[i].y > a[j].y)
      f[j] = (f[j] + g[i]) % MOD;
    else
      g[i] = (f[j] + g[i]) % MOD;
  }
  ll sum = 0;
  rep(i, 1, n) sum += f[i] + g[i] - 1;
  cout << sum % MOD;
  return 0;
}